home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / tsipp / tsipp.lha / tsipp3.0a / tests / testprocs.tcl < prev    next >
Encoding:
Text File  |  1992-11-02  |  2.1 KB  |  78 lines

  1.  
  2. #
  3. # Run code and check the result.
  4. #
  5. proc test {test_name contents_of_test expect_result_code passing_results} {
  6.     global errorInfo
  7.     set result_code [catch {uplevel $contents_of_test} answer]
  8.  
  9.     if {("$answer" != "$passing_results") || 
  10.             ($result_code != $expect_result_code)} { 
  11.     puts stdout [replicate - 60]
  12.     puts stdout "$test_name: FAILED:"
  13.         puts stdout "$contents_of_test"
  14.     puts stdout "---- Returned: ($result_code)"
  15.         puts stdout "$answer"
  16.     puts stdout "---- Result should have been: ($expect_result_code)"
  17.     puts stdout "$passing_results"
  18.     puts stdout "---- $test_name FAILED" 
  19.     }
  20. }
  21.  
  22.  
  23. #
  24. # Function to set up an object to render.
  25. #
  26.  
  27. proc Ellipsoid {} {
  28.     SippLightSourceCreate { 1.0  1.0 1.0} {0.9 1.0 0} DIRECTION
  29.     SippLightSourceCreate {-1.0 -1.0 0.5} {1   1   1} DIRECTION 
  30.  
  31.     set shader [SippShaderBasic 0.5 0.6 0.2 {0.6 0.3 0.5}]
  32.     set elipOH [SippEllipsoid {1.0 2.0 3.0} 15 $shader WORLD]
  33.     SippObjectScale $elipOH 0.5
  34.  
  35.     SippObjectAddSubobj WORLD $elipOH
  36.  
  37.     set camera [SippCameraCreate {10.0 0.0 0.0} {0.0 0.0 0.0} {0.0 0.0 1.0}]
  38.     SippCameraUse $camera
  39.     SippShaderDelete $shader
  40.     SippObjectDelete $elipOH
  41. }
  42.  
  43. #
  44. # Check if a file exists and what it size is.  Outputs a warning if its
  45. # not the exact size, but within 4000 bytes.  I don't know why we get the
  46. # variation in RLE file size, but the pictures look the same.
  47. #
  48. proc CheckFile {filename size} {
  49.     if {![file exists $filename]} {        
  50.         error "$filename does not exist
  51.     }
  52.     set actualSize [file size $filename]
  53.     if {$actualSize < ($size - 4000) || $actualSize > ($size + 4000)} {
  54.         error "Wrong file size, expected close to: $size, got: $actualSize"
  55.     }
  56. }
  57.  
  58. #
  59. # Matrices used in some tests.
  60. #
  61.  
  62. global identityMat testMat1 testMat2
  63.  
  64. set identityMat [list {1 0 0 0} \
  65.                       {0 1 0 0} \
  66.                       {0 0 1 0} \
  67.                       {0 0 0 1}]
  68.  
  69. set testMat1 [list {2 0 0 0} \
  70.                    {0 3 0 0} \
  71.                    {0 5 1 0} \
  72.                    {0 7 0 1}]
  73.  
  74. set testMat2 [list {2 0 0 0} \
  75.                    {4 6 0 0} \
  76.                    {7 5 1 0} \
  77.                    {1 7 0 1}]
  78.